using System;
using UnityEngine;

[Serializable]
public class marketButtons3D : MonoBehaviour
{
	public GameObject parts;

	public GameObject attackp;

	public GameObject basep;

	public GameObject weightp;

	public GameObject chipp;

	public GameObject cordp;

	public GameObject prebuiltp;

	public movelimit movelimitch;

	public movelimit movelimitat;

	public movelimit movelimitwe;

	public movelimit movelimitba;

	public movelimit movelimitco;

	public movelimit movelimitpr;

	public GameObject buyHud;

	public GameObject bg;

	public AudioClip clip;

	public Color pressed;

	public Color unpressed;

	public Collider back;

	public Collider attackring;

	public Collider chip;

	public Collider weightdisk;

	public Collider @base;

	public Collider cord;

	public Collider prebuilt;

	public Camera mainCamera;

	public PartMarket partMarket;

	public GameObject hideads;

	public Camera textcam;

	private string levelToBack;

	public void Awake()
	{
		if (WorkshopButtons3D.fromWorkshop)
		{
			levelToBack = "workshop";
			((bback)GetComponent(typeof(bback))).scene = "workshop";
		}
		else
		{
			levelToBack = "mainmenu2";
		}
		WorkshopButtons3D.fromWorkshop = false;
	}

	public void Start()
	{
		partMarket = (((PartMarket)UnityEngine.Object.FindObjectOfType(typeof(PartMarket))) as PartMarket);
	}

	public void Update()
	{
		if (Input.GetMouseButtonUp(0))
		{
			st();
		}
		if (!Input.GetMouseButtonDown(0))
		{
			return;
		}
		RaycastHit hitInfo = default(RaycastHit);
		if (Physics.Raycast(mainCamera.ScreenPointToRay(UnityEngine.Input.mousePosition), out hitInfo, 100f))
		{
			if (hitInfo.collider.name == "InfoToggle")
			{
				((SpecialAttackInfo)hitInfo.collider.GetComponent(typeof(SpecialAttackInfo))).ShowInfo();
			}
			else if (hitInfo.collider.name == "Back")
			{
				AudioSource.PlayClipAtPoint(clip, Camera.main.transform.position);
				back.GetComponent<Renderer>().material.color = pressed;
				back.GetComponent<Renderer>().material.SetColor("_SpecColor", pressed);
				UnityEngine.SceneManagement.SceneManager.LoadScene(levelToBack);
				buyHud.SetActiveRecursively(state: false);
			}
			else if (hitInfo.collider.name == "AttackRing")
			{
				UnityEngine.Object.Instantiate(hideads);
				AudioSource.PlayClipAtPoint(clip, Camera.main.transform.position);
				attackring.GetComponent<Renderer>().material.color = pressed;
				attackring.GetComponent<Renderer>().material.SetColor("_SpecColor", pressed);
				partMarket.allowed = true;
				attackp.SetActiveRecursively(state: true);
				chipp.SetActiveRecursively(state: false);
				basep.SetActiveRecursively(state: false);
				weightp.SetActiveRecursively(state: false);
				cordp.SetActiveRecursively(state: false);
				bg.SetActiveRecursively(state: true);
				prebuiltp.SetActiveRecursively(state: false);
				buyHud.SetActiveRecursively(state: true);
				movelimitat.limit();
			}
			else if (hitInfo.collider.name == "Base")
			{
				UnityEngine.Object.Instantiate(hideads);
				AudioSource.PlayClipAtPoint(clip, Camera.main.transform.position);
				@base.GetComponent<Renderer>().material.color = pressed;
				@base.GetComponent<Renderer>().material.SetColor("_SpecColor", pressed);
				partMarket.allowed = true;
				attackp.SetActiveRecursively(state: false);
				chipp.SetActiveRecursively(state: false);
				basep.SetActiveRecursively(state: true);
				weightp.SetActiveRecursively(state: false);
				cordp.SetActiveRecursively(state: false);
				prebuiltp.SetActiveRecursively(state: false);
				bg.SetActiveRecursively(state: true);
				buyHud.SetActiveRecursively(state: true);
				movelimitba.limit();
			}
			else if (hitInfo.collider.name == "Chip")
			{
				UnityEngine.Object.Instantiate(hideads);
				AudioSource.PlayClipAtPoint(clip, Camera.main.transform.position);
				chip.GetComponent<Renderer>().material.color = pressed;
				chip.GetComponent<Renderer>().material.SetColor("_SpecColor", pressed);
				partMarket.allowed = true;
				attackp.SetActiveRecursively(state: false);
				chipp.SetActiveRecursively(state: true);
				basep.SetActiveRecursively(state: false);
				weightp.SetActiveRecursively(state: false);
				cordp.SetActiveRecursively(state: false);
				prebuiltp.SetActiveRecursively(state: false);
				bg.SetActiveRecursively(state: true);
				movelimitch.limit();
			}
			else if (hitInfo.collider.name == "WeightDisk")
			{
				UnityEngine.Object.Instantiate(hideads);
				AudioSource.PlayClipAtPoint(clip, Camera.main.transform.position);
				weightdisk.GetComponent<Renderer>().material.color = pressed;
				weightdisk.GetComponent<Renderer>().material.SetColor("_SpecColor", pressed);
				partMarket.allowed = true;
				attackp.SetActiveRecursively(state: false);
				chipp.SetActiveRecursively(state: false);
				basep.SetActiveRecursively(state: false);
				weightp.SetActiveRecursively(state: true);
				cordp.SetActiveRecursively(state: false);
				prebuiltp.SetActiveRecursively(state: false);
				bg.SetActiveRecursively(state: true);
				buyHud.SetActiveRecursively(state: true);
				movelimitwe.limit();
			}
			else if (hitInfo.collider.name == "Cord")
			{
				UnityEngine.Object.Instantiate(hideads);
				AudioSource.PlayClipAtPoint(clip, Camera.main.transform.position);
				cord.GetComponent<Renderer>().material.color = pressed;
				cord.GetComponent<Renderer>().material.SetColor("_SpecColor", pressed);
				partMarket.allowed = true;
				attackp.SetActiveRecursively(state: false);
				chipp.SetActiveRecursively(state: false);
				basep.SetActiveRecursively(state: false);
				weightp.SetActiveRecursively(state: false);
				cordp.SetActiveRecursively(state: true);
				bg.SetActiveRecursively(state: true);
				prebuiltp.SetActiveRecursively(state: false);
				movelimitco.limit();
			}
			else if (hitInfo.collider.name == "Prebuilt")
			{
				UnityEngine.Object.Instantiate(hideads);
				AudioSource.PlayClipAtPoint(clip, Camera.main.transform.position);
				prebuilt.GetComponent<Renderer>().material.color = pressed;
				prebuilt.GetComponent<Renderer>().material.SetColor("_SpecColor", pressed);
				partMarket.allowed = true;
				attackp.SetActiveRecursively(state: false);
				chipp.SetActiveRecursively(state: false);
				basep.SetActiveRecursively(state: false);
				weightp.SetActiveRecursively(state: false);
				cordp.SetActiveRecursively(state: false);
				prebuiltp.SetActiveRecursively(state: true);
				bg.SetActiveRecursively(state: true);
				movelimitpr.limit();
			}
		}
	}

	public void st()
	{
		back.GetComponent<Renderer>().material.color = unpressed;
		attackring.GetComponent<Renderer>().material.color = unpressed;
		@base.GetComponent<Renderer>().material.color = unpressed;
		chip.GetComponent<Renderer>().material.color = unpressed;
		weightdisk.GetComponent<Renderer>().material.color = unpressed;
		cord.GetComponent<Renderer>().material.color = unpressed;
		prebuilt.GetComponent<Renderer>().material.color = unpressed;
		back.GetComponent<Renderer>().material.SetColor("_SpecColor", Color.white);
		attackring.GetComponent<Renderer>().material.SetColor("_SpecColor", Color.white);
		@base.GetComponent<Renderer>().material.SetColor("_SpecColor", Color.white);
		chip.GetComponent<Renderer>().material.SetColor("_SpecColor", Color.white);
		weightdisk.GetComponent<Renderer>().material.SetColor("_SpecColor", Color.white);
		cord.GetComponent<Renderer>().material.SetColor("_SpecColor", Color.white);
		prebuilt.GetComponent<Renderer>().material.SetColor("_SpecColor", Color.white);
	}

	public void Main()
	{
	}
}
